//A rollover for a pinball machine
//
// (c)2012 Felipe Sanches <fsanches@metamaquina.com.br>
// licensed under GPLv3 or later
//
// Part number: #A-12688-1
// http://www.marcospecialties.com/pinball-parts/A-12688-1

black_plastic_color = [0.1, 0.1, 0.1];
metal_color = "silver";

module bent_wire(){
  width = 1.5;
  rotate([90,0])
  translate([0,0,-width/2])
  linear_extrude(height=width)
  import("rollover.dxf", layer="bentwire");
}

module contact_switch(){
  rotate([90,0]){
    color(black_plastic_color)
    translate([0,0,-3])
    linear_extrude(height=6)
    import("rollover.dxf", layer="plastic");

    color(metal_color)
    translate([0,0,-2])
    linear_extrude(height=4)
    import("rollover.dxf", layer="metal");  
  }
}

module rollover_mount(){
  //TODO: fix this rough approximation
  color(metal_color)
  rotate([90,0]){
    translate([0,0,-3 -2])
    linear_extrude(height=2)
    import("rollover.dxf", layer="mount-switch");

    translate([0,0,-3])
    linear_extrude(height=6)
    import("rollover.dxf", layer="limiter");

    difference(){
      translate([0,0,-3 -10])
      linear_extrude(height=10)
      import("rollover.dxf", layer="mount-screws");
      
      //screw holes
      translate([51-5, 0, -3 -5])
      rotate([90,0]) 
      cylinder(r=2, $fn=20, center=true, h=10);

      translate([51+5, 0, -3 -5])
      rotate([90,0])
      cylinder(r=2, $fn=20, center=true, h=10);
    }
  }
}

module rollover_mount_holes_2d(){
  length = 40;
  width = 4;

  hull(){
    translate([0, -length/2])
    circle(r=width/2, $fn=30);

    translate([0, length/2])
    circle(r=width/2, $fn=30);
  }
}

module rollover_mount_holes(playfield_thickness=15){
  translate([0,0,-playfield_thickness-1])
  linear_extrude(height=playfield_thickness+2)
  rollover_mount_holes_2d();
}

module rollover(){
  rotate([0,0,-90])
  translate([-15,0]){
    bent_wire();
    contact_switch();
    rollover_mount();
  }
}

rollover();
%rollover_mount_holes();

